package com.huajx.armp.htxny.server;

import com.huajx.armp.htxny.adapter.HtxnyHandlerAdapter;
import com.huajx.armp.htxny.codec.HtxnyDecoder;
import com.huajx.armp.htxny.codec.HtxnyEncoder;
import com.huajx.core.handler.ServerHandlerFactory;
import com.huajx.core.server.annonation.MinaServer;
import com.huajx.core.server.impl.BaseTcpServer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

/**
 * @author: lisa 叶新华
 * @create: 2020-03-25 15:06
 */
@MinaServer(name = "htxny", port = 11001)
public class HtxnyServer extends BaseTcpServer {

    @Override
    protected ServerHandlerFactory getHandler() {
        return new HtxnyHandlerAdapter();
    }

    @Override
    protected ProtocolCodecFactory getProtocolCodecFactory() {
        return new ProtocolCodecFactory() {
            @Override
            public ProtocolEncoder getEncoder(IoSession session) throws Exception {
                return new HtxnyEncoder();
            }

            @Override
            public ProtocolDecoder getDecoder(IoSession session) throws Exception {
                return new HtxnyDecoder();
            }
        };
    }

    @Override
    protected void initial() {

    }
}
